Assignment 2

Objectives



  • To make a smart alert system for regulator based machines.

  • To make use of LEDs to display different value limits reached on regulator.

  • To make use of buzzer to indicated maximum value reached on those different limits.


Devices/Components used



  • Arduino UNO : Controller

  • Potentiometer : Analog Input

  • Buzzer : Output

  • RGB LED : Output

  • Breadboard

  • M-M Connectors

Software Used : Arduino IDE



Circuit and Wiring





Arduino Code



For Arduino Code click here.

#define BLUE 3                                                                    
#define GREEN 5                                                                   
#define RED 6                                                                     
                                                                                  
// the setup routine runs once when you press reset:                              
void setup() {                                                                    
  // initialize serial communication at 9600 bits per second:                     
  Serial.begin(9600);                                                             
  pinMode(RED, OUTPUT);                                                           
  pinMode(GREEN, OUTPUT);                                                         
  pinMode(BLUE, OUTPUT);                                                          
}                                                                                 
                                                                                  
// the loop routine runs over and over again forever:                             
void loop() {                                                                     
  // read the input on analog pin 0:                                              
  int sensorValue = analogRead(A0);                                               
  // print out the value you read:                                                
  Serial.println(sensorValue);                                                    
                                                                                  
  if (sensorValue >=0 && sensorValue <256) {                                      
    RGB_color(sensorValue%255, 0, 0);                                             
  }                                                                               
  else if (sensorValue >=256 && sensorValue <511) {                               
    RGB_color(0, sensorValue%255, 0);                                             
  }                                                                               
  else if (sensorValue >=511 && sensorValue <766) {                               
    RGB_color(0, 0,sensorValue%255);                                              
  }                                                                               
  else {                                                                          
    RGB_color(sensorValue%255,sensorValue%255, sensorValue%255);                  
  }                                                                               
                                                                                  
  //delay(1000);        // delay in between reads for stability                   
}                                                                                 
                                                                                  
                                                                                  
void RGB_color(int red_light_value, int green_light_value, int blue_light_value)  
 {                                                                                
  analogWrite(RED, red_light_value);                                              
  analogWrite(GREEN, green_light_value);                                          
  analogWrite(BLUE, blue_light_value);                                            
}                                                                                 

Summary Video

Here is a video to show the working of the circuit and program.



Conclusion


  • The smart alert system for regulator based machines worked properly and corresponding values were shown on the serial monitor.

  • The RGB LED displayed different colours for different value limits reached on regulator.

  • The buzzer made different sounds to indicated maximum value reached on those different limits.